package collector.listener;

import java.awt.event.KeyEvent;

import thread.ThreadToggle;
import bean.util.WindowUtil;
import br.com.wagnerpaz.javahook.NativeKeyboardEvent;
import br.com.wagnerpaz.javahook.NativeKeyboardListener;

import com.sun.jna.platform.win32.WinDef.HWND;

public class CollectorKeyboardListener implements NativeKeyboardListener {

	public boolean keyPressed(NativeKeyboardEvent e) {
		if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
			ThreadToggle.KEEP_RUNNING = false;

			WindowUtil.closeWindow(WindowUtil.toolWin);
			for (HWND hwnd : WindowUtil.cgWins) {
				WindowUtil.closeWindow(hwnd);
			}
		} else if (e.getKeyCode() == KeyEvent.VK_F1) {
			ThreadToggle.KEEP_RUNNING = true;

			WindowUtil.activeWindow(WindowUtil.toolWin);
			for (HWND hwnd : WindowUtil.cgWins) {
				WindowUtil.activeWindow(hwnd);
			}
		} else if (e.getKeyCode() == KeyEvent.VK_F2) {
			ThreadToggle.KEEP_RUNNING = false;
		}

		return true;
	}

	public boolean keyReleased(NativeKeyboardEvent e) {
		return true;
	}

}
